import re


# compiler
tt = "Saly is a good girl, she is cool, clever, and so on..."
rr = re.compile(r'\w*oo\w*')


# match
print(re.match('sss','sssaaa.rudfadfssncomoob').group())
print(re.match('sss','sssttt.sdfdsss',re.I).group())

# search
print(re.search('com','www.baidu.com.5com').group())


print(rr.findall(tt))


# finditer
iter = re.finditer(r'\d+','435243 drummdfdsf44ers fgasf, 11 ... 10 ...')
for i in iter:
    print(i)
    print(i.group())
    print(i.span())


# split
print(re.split('\d+','dsfadfasdfr4fasfd'))


# sub
text = "dsfdf is a handsome aaa, he is handsome, clever, and so on..."
print(re.sub(r'\s+', '-', text))


# subn
print(re.subn('[1-4]','A','12345678fsdadsf'))
print(re.sub("g.t","have",'I get A,  I got B ,I gut C'))